<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
        }
        .red {
            background-color: #f00;
        }

        .bigBd {
            border: 10px solid #000;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click="isRed = !isRed">切换颜色</button>
        <button @click="isBig = !isBig">切换边框</button>
        <div class="box" :class="{ red: isRed, bigBd: isBig}"></div>

        <!-- 用的比较少的写法如下，传入数组 -->
        <!-- 此时此刻代表cls1和cls2是什么，他就有什么类 -->
        <div class="box" :class="[cls1, cls2]"></div>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                isRed: true,
                isBig: true,
                cls1: 'xx',
                cls2: 'zz'
            }
        })
    </script>
</body>
</html>